package BehaviorModel.iterorModel;

import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

public class InfoIteror implements Iterator {

    List<Department> departments;

    private int index = 0;

    public InfoIteror(List<Department> departments) {
        this.departments = departments;
        this.index = 0;
    }

    public void setDepartments(List<Department> departments) {
        this.departments = departments;
        this.index = 0; // 重置游标索引
    }
    @Override
    public boolean hasNext() {
        if (index+1 > departments.size()){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        if (hasNext()){
            return departments.get(index++);
        }
        return null;
    }

    /**
     * 功能描述: 移除默认空实现
     */
    @Override
    public void remove() {

    }


}
